package com.pek.control.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pek.control.dao.ConfigMapper;
import com.pek.control.entity.ConfigEntity;
import com.pek.control.service.IConfigService;
import org.springframework.stereotype.Service;

@Service
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, ConfigEntity> implements IConfigService {

    @Override
    public ConfigEntity getObject(String key) {
        return this.getOne(new LambdaQueryWrapper<ConfigEntity>().eq(ConfigEntity::getConfigKey,key));
    }

    @Override
    public String getValue(String key) {
        var obj=getObject(key);
        if(StringUtils.isEmpty(key)){
            return null;
        }
        return obj.getConfigValue();
    }
}
